package sum.book.auth.api.fallback;


import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import sum.book.auth.api.feign.BookOauthServerClient;
import sum.book.common.core.model.dto.TokenDTO;

import static sum.book.common.core.utils.ResponseUtil.getResponseEntity;


/**
 * @Auther: ZhangGN
 * @Description:
 * @Date 2022/12/20 10:48
 **/
@Component
public class BookOauthServerFallbackFactory implements FallbackFactory<BookOauthServerClient> {

    @Override
    public BookOauthServerClient create(Throwable cause) {
        return new BookOauthServerClient() {
            @Override
            public ResponseEntity<TokenDTO> token(String basicAuth, String username, String password, String grantType) {
                return getResponseEntity(cause);
            }
        };
    }

}
